// Copyright (C) 2025 Focus Media Holding Ltd. All Rights Reserved.

package cn.pacerx.running.wx.web;

import cn.pacerx.running.wx.dto.WechatLoginDto;
import cn.pacerx.running.wx.service.AuthService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * AuthController
 *
 * @author zhanglingwei@focusmedia.cn
 * @since 2025-06-09
 */
@RestController
@RequestMapping("/wx/auth/wechat")
@RequiredArgsConstructor
public class AuthController {
    private final AuthService authService;

    /**
     * 微信登录
     *
     * @param wechatLoginDto 请求内容，{ code: xxx }
     * @param request        请求对象
     * @return 登录结果
     */
    @ApiOperation("微信小程序登录")
    @PostMapping("/login")
    public Object loginByWechat(@RequestBody @Valid WechatLoginDto wechatLoginDto, HttpServletRequest request) {
        return authService.loginByWechat(wechatLoginDto, request);
    }


}
